Skip to content

Special case comparisons between LazyRefs and bottom/top types #11069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 12, 2021

Fixes #11064

When comparing a LazyRef with some other type, we need to force the LazyRef
which can potentially lead to a cycle (as observed in #11064). However, in the situations

Nothing <: LazyRef(...)
LazyRef(...) <: Any

we can skip that since the comparison is always true. This scheme fixes #11064, but it breaks
down in similar situations if additional bounds are introduced (see neg-custom-args/allow-deep-subtypes/i11064.scala).
So it is quite fragile. But it's probably the best we can do.

The example in #11064 looks harmless, but type-theoretically it's actually a pretty explosive
mix of F-bounded types and existential types (in Scala 2). In Scala 3, we need to force more
for F-bounded types and we need to approximate existential types by dependent types, so
not everything works the same way.

My long term advice would be: get rid of F-bounds. Model them with intersections at the
use site
.

Fixes scala#11064

When comparing a LazyRef with some other type, we need to force the LazyRef
which can potentially lead to a cycle (as observed in scala#11064). However, in the situations
```
Nothing <: LazyRef(...)
LazyRef(...) <: Any
```
we can skip that since the comparison is always true. This scheme fixes scala#11064, but it breaks
down in similar situations if additional bounds are introduced (see neg/i11064.scala).
So it is quite fragile. But it's probably the best we can do.

The example in scala#11064 looks harmless, but type-theoretically it's actually a pretty explosive
mix of F-bounded types and existential types (in Scala 2). In Scala 2, we need to force more
for F-bounded types and we need to approximate existential types by dependent types, so
not everything works the same way.

My long term advice would be: get rid of F-bounds. Model them with intersections at the
use site.
@odersky odersky requested a review from nicolasstucki January 12, 2021 16:33
@odersky odersky added the fasttrack Simple fix. Reviewer should merge or apply additional changes directly. label Jan 12, 2021
@odersky odersky merged commit 4c27adf into scala:master Jan 13, 2021
@odersky odersky deleted the fix-#11064 branch January 13, 2021 17:38
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fasttrack Simple fix. Reviewer should merge or apply additional changes directly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

infinite recursion in Scala.js using 3.0.0-M3 due to compiler error in dotty.
3 participants